import 'dart:collection';

import 'package:dio/dio.dart';
import 'package:retrofit/retrofit.dart';
import '../bean/FoundTabListData.dart';
import 'package:meePet/bean/RolePageData.dart';

import '../bean/GeekRegisterData.dart';
import '../bean/LoginEncryptData.dart';
import '../bean/RobotVerifyData.dart';
import '../bean/SendSMSData.dart';
import '../bean/TabConfigData.dart';
import '../bean/ValityKeyData.dart';

part 'CommonApi.g.dart';

///增加新方法请在命令窗口运行：dart pub run build_runner build
///会自动生成retrofit代码、flutter会tree shaken自动删除代码，不能使用反射的，只能生成代码调用
///https://pub.dev/packages/retrofit
@RestApi(baseUrl: 'https://api.xingyunxcx.com')
abstract class CommonClient {
  factory CommonClient(Dio dio, {String baseUrl}) = _CommonClient;

  @GET('/gift/v1/getGiftItem')
  Future<dynamic> getGiftList();

  ///首页tab
  @GET('/app/v1/tabs')
  Future<TabConfigData> getTabs(@Query('appVersion') String appVersion,
      @Query('appMarket') String appMarket);

  ///发现页选项列表
  @GET('/page/tab/v1/options')
  Future<FoundTabListData> options(@Query('positionId') String positionId);

  ///角色分页列表
  ///tabId tabAlias categoryIds keyword sortType pageNo pageSize sortField sortOrder
  @GET('/chat/aiRole/v1/pageList')
  Future<RolePageData> rolePageList(@Queries() Map<String, dynamic> params);


  ///动态获取加密，解密key（只属于本机用户,有时效性）
  @GET('/ct/v1/vitasoy')
  Future<ValityKeyData> getVitasoy();

  ///sim卡登录
  @POST('/login/v1/smsLogin')
  Future<LoginEncryptData> smsLogin(@Body() HashMap<String, dynamic> params);

  ///极验注册
  @GET('/gt/v1/register')
  Future<GeekRegisterData> geekRegister();

  ///发送短信验证码
  ///@param see GeekVerifyData.Data need decode json from GeekSDK's Result
  @GET("/sms/v1/sendCaptcha")
  Future<SendSmsData> sendSMS(@Body() HashMap<String, dynamic> params);

  ///获取人机验证，及验证码倒计时
  @GET("/gt/v1/imgCaptcha")
  Future<RobotVerifyData> robot(@Query('requestId') String requestId);
}
